package top.withu.gaof.freehope.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.qiniu.common.QiniuException;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import top.withu.gaof.freehope.annotate.PassCheck;
import top.withu.gaof.freehope.res.FileRes;
import top.withu.gaof.freehope.service.impl.FileServiceImpl;

/**
 * @author Gaofan
 * @date 2018年12月24日 下午2:35:32
 * @describe 文件上传
 */
@RestController
@Api(value = "file", description = "文件处理模块")
public class FileController {

	@Autowired
	private FileServiceImpl fileserviceImpl;

	@ApiOperation(notes = "文件处理模块-文件上传", value = "/file/info", httpMethod = "POST")
	@RequestMapping(value = "/file/info", method = RequestMethod.POST)
	@PassCheck
	public FileRes getTradeInfo(@RequestParam("file") MultipartFile file, @RequestParam("type") String type,
			@RequestParam("user") String user) throws QiniuException {
		return fileserviceImpl.uploadFile(file, type, user);
	}

}
